import socket
def get_host_ip():
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(('8.8.8.8', 80))
        ip = s.getsockname()[0]
    finally:
        s.close()
    return ip

class DEV():
    ##▁▂▃▅▆▇_____________________app-server 信息___________________________▇▆▅▃▂▁
    HOST = get_host_ip()
    PORT = 5000

    REDIS_CONFIG = {

        "host": "127.0.0.1",
        "port": 6379,
        "password": "",

    }

    #postgresql
    PG_APP_CONF={
        'host': '127.0.0.1',
        'port': "5432",
        'user': 'postgres',
        'dbname': 'test',
        'password': '123456'
    
    }

    MYSQL_APP_CONF={
        'host': '127.0.0.1',
        'port': "3306",
        'user': 'root',
        'dbname': 'test',
        'password': '123456'
    
    }


class CeleryConfig_Dev:  # pylint: disable=too-few-public-methods
    from celery import platforms
    from kombu import Exchange, Queue
    platforms.C_FORCE_ROOT = True
    #redis
    broker_url = 'redis://:'

    #pgsql
    result_backend = 'db+postgresql://'
    # result_backend = 'redis://:xiaobao321@A@172.26.36.188:6379'
    # task_serializer = 'json'
    # 包含的任务路径
    include=['applications.service','applications.service']
    # result_serializer = 'json'
    # accept_content = ['json']
    timezone = 'Asia/Shanghai'
    result_extended = True
    # database_engine_options = {'echo': True}
    database_table_schemas = {
        'task': 'sanic',
        'group': 'sanic',
    }
    database_table_names = {
        'task': 'sanic_celery_taskmeta',
        'group':'sanic_celery_taskmeta',
    }

    task_queues = (

    Queue("work_A",Exchange("work_A"),routing_key="work_A"),

    # Queue("data_operator_B",Exchange("data_operator_B"),routing_key="data_operator_B")

    )


    task_routes = {
    # 'celery_task.task':{"queue":"for_task_A","routing_key":"for_task_A"},
    }


    task_default_exchange = "work_A"
    task_default_queue = "work_A"
    task_default_routing_key = "work_A"